package com.heatup.apt.management.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import com.heatup.apt.common.dao.ResourceMapper;
import com.heatup.apt.management.service.OperativeService;
import com.heatup.apt.model.management.CoachInf;

import net.sf.json.JSONObject;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("system/operative")
public class OperativeController extends BaseController{

	@Resource
	private OperativeService operativeService;
	
	@Autowired
	private ResourceMapper resourceMapper;
	
	/**
	 * 跳转到首页轮播
	 * OperativeController.to_operating_manage()<BR>
	 * <P>Author :  fangxiaowen </P>  
	 * <P>Date : 2016年9月22日 </P>
	 * @param request
	 * @param response
	 * @return
	 */
    @RequestMapping(value = "to_operating_manage",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operating_manage(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
        model.setViewName("operative/operating-manage");
        return model;
    }
    
    /**
     * 跳转到添加文章页面
     * OperativeController.to_operative_add_article()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月30日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_operative_add_article",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operative_add_article(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	
    	List<CoachInf> coachInfos = operativeService.queryCoachInfList();
    	request.setAttribute("coachInfos", coachInfos);
    	model.setViewName("operative/operative-add-article");
    	return model;
    }
    
    /**
     * 跳转到添加轮播
     * OperativeController.to_operating_add()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月22日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_operating_add",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operating_add(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	model.setViewName("operative/operating-add-banner");
    	return model;
    }
    
    /**
     * 跳转到最受欢迎课程
     * OperativeController.to_operating_add_zsyhkc()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年10月31日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_operating_add_zsyhkc",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operating_add_zsyhkc(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	model.setViewName("operative/operating-add-zsyhkc");
    	return model;
    }
    
    /**
     * 跳转到进店模式添加轮播
     * OperativeController.operating_add_instore()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月30日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_operating_add_instore",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operating_add_instore(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	model.setViewName("operative/operating-add-instore");
    	return model;
    }
    
    /**
     * 跳转到檬店添加轮播
     * OperativeController.to_operating_add()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月22日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_operating-add-lemonbanner",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operating_add_lemonbanner(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	model.setViewName("operative/operating-add-lemonbanner");
    	return model;
    }
    
    /**
     * 添加新视频
     * OperativeController.to_operating_add_video()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月28日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_operating_add_video",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operating_add_video(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	List<CoachInf> coachInfos = operativeService.queryCoachInfList();
    	request.setAttribute("coachInfos", coachInfos);
    	
    	String res_key = request.getParameter("res_key");
    	
    	request.setAttribute("res_key", res_key);
    	model.setViewName("operative/operating-add-video");
    	return model;
    }
    
   /**
    * 檬店-添加轮播
    * OperativeController.add_figures()<BR>
    * <P>Author :  fangxiaowen </P>  
    * <P>Date : 2016年9月23日 </P>
    * @param request
    * @param response
    */
   @RequestMapping(value = "operating_add_lemonbanner",method = {RequestMethod.POST})
   public void operating_add_lemonbanner(HttpServletRequest request, HttpServletResponse response) {
   	try {
   		request.setCharacterEncoding("UTF-8"); 
   		int count = 0;
       	String title = request.getParameter("title");
       	String previewUrl = request.getParameter("previewUrl");
       	
       	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
       	Map<String,MultipartFile> map= mhsr.getFileMap();
   		if (!map.values().isEmpty()) {
   			for (MultipartFile mf : map.values()) {
   				try {
   					count = operativeService.addLemonbanner(mf, request, title, previewUrl,getUserInfo());
   				} catch (Exception e) {
   					e.printStackTrace();
   				}
   			}
   		}
   		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "添加失败!");
		}
   }
   
   /**
    * 进店模式-添加轮播保存
    * OperativeController.operating_add_lemonbanner()<BR>
    * <P>Author :  fangxiaowen </P>  
    * <P>Date : 2016年9月30日 </P>
    * @param request
    * @param response
    */
   @RequestMapping(value = "operating_add_instore",method = {RequestMethod.POST})
   public void operating_add_instore(HttpServletRequest request, HttpServletResponse response) {
	   try {
		   request.setCharacterEncoding("UTF-8"); 
		   int count = 0;
		   String title = request.getParameter("title");
		   String previewUrl = request.getParameter("previewUrl");
		   
		   MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
		   Map<String,MultipartFile> map= mhsr.getFileMap();
		   if (!map.values().isEmpty()) {
			   for (MultipartFile mf : map.values()) {
				   try {
					   count = operativeService.addInstore(mf, request, title, previewUrl, getUserInfo());
				   } catch (Exception e) {
					   e.printStackTrace();
				   }
			   }
		   }
		   responseSendMsg(response, count + "");
	   } catch (Exception e) {
		   e.printStackTrace();
		   responseSendMsg(response, "添加失败!");
	   }
   }
   
   /**
    * 添加文章
    * OperativeController.add_acricle()<BR>
    * <P>Author :  fangxiaowen </P>  
    * <P>Date : 2016年9月30日 </P>
    * @param request
    * @param response
    */
   @RequestMapping(value = "add_acricle",method = {RequestMethod.POST})
   public void add_acricle(HttpServletRequest request, HttpServletResponse response) {
	   try {
		   request.setCharacterEncoding("UTF-8"); 
		   int count = 0;
		   String title = request.getParameter("title");
		   String remark = request.getParameter("remark");
		   String link = request.getParameter("link");
		   String coachId = request.getParameter("coachId");
		   MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
		   Map<String,MultipartFile> map= mhsr.getFileMap();
		   if (!map.values().isEmpty()) {
			   for (MultipartFile mf : map.values()) {
				   try {
					   count = operativeService.addArticle(mf, request, title, remark,link, coachId, getUserInfo());
				   } catch (Exception e) {
					   e.printStackTrace();
				   }
			   }
		   }
		   responseSendMsg(response, count + "");
	   } catch (Exception e) {
		   e.printStackTrace();
		   responseSendMsg(response, "添加失败!");
	   }
   }
   
   
   /**
    * 资源排序
    * OperativeController.sort_home_figure()<BR>
    * <P>Author :  fangxiaowen </P>  
    * <P>Date : 2016年10月10日 </P>
    * @param request
    * @param response
    */
   @RequestMapping(value = "sort_home_figure",method = {RequestMethod.POST,RequestMethod.GET})
   public void sort_home_figure(HttpServletRequest request, HttpServletResponse response){
		String sort_string = request.getParameter("sort_string");
		operativeService.updateSortHomeFigure(sort_string);
   }
   
   /**
    * 文章排序
    * OperativeController.sort_article()<BR>
    * <P>Author :  fangxiaowen </P>  
    * <P>Date : 2016年10月10日 </P>
    * @param request
    * @param response
    */
   @RequestMapping(value = "sort_article",method = {RequestMethod.POST,RequestMethod.GET})
   public void sort_article(HttpServletRequest request, HttpServletResponse response){
	   String sort_string = request.getParameter("sort_string");
	   operativeService.updateSortArticle(sort_string);
   }
   
   /**
    * 文章编辑保存
    * OperativeController.article_edit()<BR>
    * <P>Author :  fangxiaowen </P>  
    * <P>Date : 2016年9月30日 </P>
    * @param request
    * @param response
    */
   @RequestMapping(value = "article_edit",method = {RequestMethod.POST})
   public void article_edit(HttpServletRequest request, HttpServletResponse response) {
   	try {
   		request.setCharacterEncoding("UTF-8"); 
   		int count = 0;
       	Integer id = Integer.valueOf(request.getParameter("id"));
       	String title = request.getParameter("title");
		String remark = request.getParameter("remark");
		String link = request.getParameter("link");
		String coachId = request.getParameter("coachId");
       	MultipartFile mff = null;
       	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
       	Map<String,MultipartFile> map= mhsr.getFileMap();
		if (!map.values().isEmpty()) {
			for (MultipartFile mf : map.values()) {
   				mff = mf;
   			}
   		}
   		count = operativeService.updateArticle(mff, request, title, remark,link, coachId, id, getUserInfo());
   		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "修改失败!");
		}
   }
    
    /**
     * 添加新视频保存
     * OperativeController.operating_add_video()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月29日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "operating_add_video",method = {RequestMethod.POST, RequestMethod.GET})
    public void operating_add_video(HttpServletRequest request, HttpServletResponse response) {
    	try {
    		request.setCharacterEncoding("UTF-8"); 
    		int count = 0;
        	String title = request.getParameter("title");
        	String previewUrl = request.getParameter("previewUrl");
        	String duration = request.getParameter("duration");
        	String tags = request.getParameter("tags");
        	String coachId = request.getParameter("coachId");
        	String videoClass = request.getParameter("videoClass");
        	String res_key = request.getParameter("res_key");
        	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
        	Map<String,MultipartFile> map= mhsr.getFileMap();
			if (!map.values().isEmpty()) {
    			for (MultipartFile mf : map.values()) {
    				count = operativeService.addOperatingVideo(mf, request, title, previewUrl, tags, coachId, duration,videoClass,res_key, getUserInfo());
    			}
    		}
    		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "添加失败!");
		}
    }
    
    /**
     * 跳转到编辑页面
     * OperativeController.to_operating_edit()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月26日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_operating_edit",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_operating_edit(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	Integer id = Integer.valueOf(request.getParameter("id"));
    	request.setAttribute("elements", operativeService.toPeratingEditBanner(id));
    	model.setViewName("operative/operating-edit-banner");
    	return model;
    }
    
    
    /**
     * 跳转到文章编辑页面
     * OperativeController.to_article_edit()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月30日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_article_edit",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_article_edit(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	Integer id = Integer.valueOf(request.getParameter("id"));
    	List<CoachInf> coachInfos = operativeService.queryCoachInfList();
    	request.setAttribute("coachInfos", coachInfos);
    	request.setAttribute("elements", operativeService.queryArticleById(id));
    	model.setViewName("operative/operative-edit-article");
    	return model;
    }
    
    /**
     * 跳转到视频编辑页面
     * OperativeController.to_video_edit()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月29日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to_video_edit",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView to_video_edit(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	Integer id = Integer.valueOf(request.getParameter("id"));
    	List<CoachInf> coachInfos = operativeService.queryCoachInfList();
    	request.setAttribute("coachInfos", coachInfos);
    	request.setAttribute("elements", operativeService.toPeratingEditBanner(id));
    	model.setViewName("operative/operating-edit-video");
    	return model;
    }
    
    /**
     * 首页轮播图编辑保存
     * OperativeController.operating_edit()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月27日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "operating_edit",method = {RequestMethod.POST})
    public void operating_edit(HttpServletRequest request, HttpServletResponse response) {
    	try {
    		request.setCharacterEncoding("UTF-8"); 
    		int count = 0;
        	String title = request.getParameter("title");
        	String previewUrl = request.getParameter("previewUrl");
        	Integer id = Integer.valueOf(request.getParameter("id"));
        	MultipartFile mff = null;
        	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
        	Map<String,MultipartFile> map= mhsr.getFileMap();
    		if (!map.values().isEmpty()) {
    			for (MultipartFile mf : map.values()) {
    				mff = mf;
    			}
    		}
    		count = operativeService.updateHomeFigure(mff, request, title, previewUrl, id, getUserInfo());
    		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "添加失败!");
		}
    }
    
    /**
     * 视频编辑保存
     * OperativeController.video_edit()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月29日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "video_edit",method = {RequestMethod.POST})
    public void video_edit(HttpServletRequest request, HttpServletResponse response) {
    	try {
    		request.setCharacterEncoding("UTF-8"); 
    		int count = 0;
        	String title = request.getParameter("title");
        	String previewUrl = request.getParameter("previewUrl");
        	String duration = request.getParameter("duration");
        	String tags = request.getParameter("tags");
        	String coachId = request.getParameter("coachId");
        	String videoClass = request.getParameter("videoClass");
        	String id = request.getParameter("id");
        	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
        	Map<String,MultipartFile> map= mhsr.getFileMap();
        	MultipartFile mff = null;
			if (!map.values().isEmpty()) {
    			for (MultipartFile mf : map.values()) {
    				mff = mf;
    			}
    		}
    		count = operativeService.updateOperatingVideo(mff, request, title, previewUrl, tags, coachId, duration, videoClass, Integer.valueOf(id), getUserInfo());
    		responseSendMsg(response, count + "");
    	} catch (Exception e) {
    		e.printStackTrace();
    		responseSendMsg(response, "修改失败!");
    	}
    }
    
    /**
     * 文章列表
     * OperativeController.articlescrap_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月27日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/articlescrap_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void articlescrap_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryArticlescrapList();
    	jsonObject.accumulate("articlescrap_list", map.get("articlescrap_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 首页轮播列表
     * OperativeController.home_figures()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月22日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/home_figures",method = {RequestMethod.POST, RequestMethod.GET})
    public void home_figures(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryHomeFirure();
    	jsonObject.accumulate("homeFigures", map.get("homeFigures"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 进店模式-轮播图
     * OperativeController.instore_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月30日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/instore_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void instore_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryInStoreList();
    	jsonObject.accumulate("instore_list", map.get("instore_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 课程运营位-最受欢迎的课程
     * OperativeController.home_figures()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月27日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/course_banner",method = {RequestMethod.POST, RequestMethod.GET})
    public void course_banner(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryCourseBanner();
    	jsonObject.accumulate("course_banner", map.get("course_banner"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    
    /**
     * 檬店运营位置管理
     * OperativeController.lemonshop_banner()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月27日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/lemonshop_banner",method = {RequestMethod.POST, RequestMethod.GET})
    public void lemonshop_banner(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.querylemonshopBanner();
    	jsonObject.accumulate("lemonshop_banner", map.get("lemonshop_banner"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 删除首页轮播
     * OperativeController.delete_figures()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月21日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/delete_figures",method = {RequestMethod.POST, RequestMethod.GET})
    public void delete_figures(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	String id = request.getParameter("id");
    	int count = operativeService.deleteFirure(Integer.valueOf(id));
    	jsonObject.accumulate("count", count);
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 删除文章
     * OperativeController.delete_article()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月29日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/delete_article",method = {RequestMethod.POST, RequestMethod.GET})
    public void delete_article(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	String id = request.getParameter("id");
    	int count = operativeService.deleteArticle(Integer.valueOf(id));
    	jsonObject.accumulate("count", count);
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 添加轮播
     * OperativeController.add_figures()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月23日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "add_figures",method = {RequestMethod.POST})
    public void add_figures(HttpServletRequest request, HttpServletResponse response) {
    	try {
    		request.setCharacterEncoding("UTF-8"); 
    		int count = 0;
        	String title = request.getParameter("title");
        	String previewUrl = request.getParameter("previewUrl");
        	
        	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
        	Map<String,MultipartFile> map= mhsr.getFileMap();
			if (!map.values().isEmpty()) {
				for (MultipartFile mf : map.values()) {
    				try {
    					count = operativeService.addHomeFigure(mf, request, title, previewUrl,getUserInfo());
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		}
    		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "添加失败!");
		}
    }
    
    /**
     * 添加最受欢迎课程
     * OperativeController.add_zshykc()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年10月31日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "add_zshykc",method = {RequestMethod.POST})
    public void add_zshykc(HttpServletRequest request, HttpServletResponse response) {
    	try {
    		request.setCharacterEncoding("UTF-8"); 
    		int count = 0;
        	String title = request.getParameter("title");
        	String previewUrl = request.getParameter("previewUrl");
        	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
        	Map<String,MultipartFile> map= mhsr.getFileMap();
			if (!map.values().isEmpty()) {
				for (MultipartFile mf : map.values()) {
    				try {
    					count = operativeService.addZshykc(mf, request, title, previewUrl,getUserInfo());
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		}
    		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "添加失败!");
		}
    }
    
    
    /**
     * 视频列表页
     * OperativeController.video_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月21日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "video_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void video_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryVideoList();
    	jsonObject.accumulate("video_list", map.get("video_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 健身热身
     * OperativeController.jsrsvideo_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年10月9日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "jsrsvideo_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void jsrsvideo_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryJsrfVideoList();
    	jsonObject.accumulate("jsrsvideo_list", map.get("jsrsvideo_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 瘦身塑形
     * OperativeController.jsrsvideo_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年10月9日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "sfsxvideo_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void sfsxvideo_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.querySfsxVideoList();
    	jsonObject.accumulate("sfsxvideo_list", map.get("sfsxvideo_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 我要跑步
     * OperativeController.wypbvideo_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年10月9日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "wypbvideo_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void wypbvideo_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryWypbVideoList();
    	jsonObject.accumulate("wypbvideo_list", map.get("wypbvideo_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 我要蜜桃臂
     * OperativeController.wymtbvideo_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年10月17日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "wymtbvideo_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void wymtbvideo_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryWymtbVideoList();
    	jsonObject.accumulate("wymtbvideo_list", map.get("wymtbvideo_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 我要马甲线
     * OperativeController.wymjxvideo_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年10月17日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "wymjxvideo_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void wymjxvideo_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryWymjxVideoList();
    	jsonObject.accumulate("wymjxvideo_list", map.get("wymjxvideo_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    
    /**
     * 删除视频
     * OperativeController.delete_video()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月22日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/delete_video" , method = {RequestMethod.POST, RequestMethod.GET})
    public void delete_video(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	String id = request.getParameter("id");
    	int count = operativeService.deleteVideo(Integer.valueOf(id));
    	jsonObject.accumulate("count", count);
    	responseSendMsg(response, jsonObject.toString());
    }
    
    
    /**
     * 檬店轮播
     * OperativeController.lemonshop_list()<BR>
     * <P>Author :  fangxiaowen </P>  
     * <P>Date : 2016年9月21日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "lemonshop_list",method = {RequestMethod.POST, RequestMethod.GET})
    public void lemonshop_list(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryLemonShopList();
    	jsonObject.accumulate("lemonshop_list", map.get("lemonshop_list"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 会员页轮播列表
     * OperativeController.vip_figures()<BR>
     * <P>Author :  jixiangyun </P>  
     * <P>Date : 2017年4月28日 </P>
     * @param request
     * @param response
     */
    @RequestMapping(value = "/vip_figures",method = {RequestMethod.POST, RequestMethod.GET})
    public void vip_figures(HttpServletRequest request, HttpServletResponse response) {
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryVipFirure();
    	jsonObject.accumulate("vipFigures", map.get("vipFigures"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 跳转到添加轮播
     * OperativeController.operating_add_vipbanner()<BR>
     * <P>Author :  jixiangyun </P>  
     * <P>Date : 2017年4月28日 </P>
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "to-operating-add-vipbanner",method = {RequestMethod.POST, RequestMethod.GET})
    public ModelAndView operating_add_vipbanner(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView model = new ModelAndView();
    	model.setViewName("operative/operating-add-vipbanner");
    	return model;
    }
    
    @RequestMapping("/add_vipbanner")
    public void add_vipbanner(HttpServletRequest request,HttpServletResponse response){
    	try {
       		request.setCharacterEncoding("UTF-8"); 
       		int count = 0;
           	String title = request.getParameter("title");
           	String previewUrl = request.getParameter("previewUrl");
           	
           	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
           	Map<String,MultipartFile> map= mhsr.getFileMap();
       		if (!map.values().isEmpty()) {
       			for (MultipartFile mf : map.values()) {
       				try {
       					count = operativeService.addVipbanner(mf, request, title, previewUrl,getUserInfo());
       				} catch (Exception e) {
       					e.printStackTrace();
       				}
       			}
       		}
       		responseSendMsg(response, count + "");
    		} catch (Exception e) {
    			e.printStackTrace();
    			responseSendMsg(response, "添加失败!");
    		}
    }
    
    /**
     * 编辑 会员页轮播图  vipbanner
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("to_edit_vipbanner")
    public ModelAndView to_vip_baner_edit(HttpServletRequest request,HttpServletResponse response){
    	ModelAndView model = new ModelAndView();
    	Integer resourceId = Integer.valueOf(request.getParameter("resourceId"));
    	model.setViewName("operative/operating-edit-vipbanner");
    	com.heatup.apt.model.Resource resource = resourceMapper.selectByPrimaryKey(resourceId);
    	model.addObject("resource", resource);
    	return model;
    }
    
    /**
     * 编辑会员页轮播图 vipbanner
     * @param request
     * @param response
     */
    @RequestMapping("/edit_vipbanner")
    public void edit_vipbanner(HttpServletRequest request,HttpServletResponse response){
    	try {
    		String title = request.getParameter("title");
        	String previewUrl = request.getParameter("previewUrl");
        	Integer count = 0 ;
        	MultipartHttpServletRequest mhsr = (MultipartHttpServletRequest)request;
           	Map<String,MultipartFile> map= mhsr.getFileMap();
       		if (!map.values().isEmpty()) {
       			for (MultipartFile mf : map.values()) {
       				try {
       					count = operativeService.editVipbanner(mf, request, title, previewUrl,getUserInfo());
       				} catch (Exception e) {
       					e.printStackTrace();
       				}
       			}
       		}
       		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "编辑失败!");
		}
    }
    
    /**
     * 给会员页轮播图排序
     * @param request
     * @param response
     */
    @RequestMapping("/sort_vipbanner")
    public void sort_vipbanner(HttpServletRequest request,HttpServletResponse response){
    	try {
    		Integer count = 0 ;
    		String sortString = request.getParameter("sort_string");
    		count = operativeService.updateSortVipbanner(sortString);
       		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "排序失败!");
		}
    }
    
    /**
     * 获取会员活动列表
     * @param request
     * @param response
     */
    @RequestMapping("/get_vip_activity")
    public void vip_activity(HttpServletRequest request,HttpServletResponse response){
    	JSONObject jsonObject = new JSONObject();
    	Map<Object, Object> map = operativeService.queryVipActivity();
    	jsonObject.accumulate("vipActivitys", map.get("vipActivitys"));
    	responseSendMsg(response, jsonObject.toString());
    }
    
    /**
     * 打开添加会员活动页面
     * @return
     */
    @RequestMapping("/to_operating_add_vip_activity")
    public ModelAndView to_operating_add_vip_activity(){
    	ModelAndView model = new ModelAndView();
    	model.setViewName("operative/operating-add-vipactivity");
    	return model;
    }
    
    /**
     * 保存会员活动
     * @param request
     * @param response
     */
    @RequestMapping("save_activity")
    public void saveVipActivity(HttpServletRequest request,HttpServletResponse response){
    	try {
    		String title = request.getParameter("title");
        	String previewUrl = request.getParameter("previewUrl");
        	Integer count = 0 ;
        	count = operativeService.saveVipActivity(null, request, title, previewUrl, getUserInfo());
       		responseSendMsg(response, count + "");
		} catch (Exception e) {
			e.printStackTrace();
			responseSendMsg(response, "保存失败!");
		}
    }
    
    /**
     * 打开编辑会员活动编辑界面
     * @return
     */
    @RequestMapping("/to_operating_edit_vip_activity")
    public ModelAndView to_operating_edit_vip_activity(HttpServletRequest request,HttpServletResponse response){
    	ModelAndView model = new ModelAndView();
    	Integer resourceId = Integer.valueOf(request.getParameter("resourceId"));
    	com.heatup.apt.model.Resource resource = resourceMapper.selectByPrimaryKey(resourceId);
    	model.addObject("resource", resource);
    	model.setViewName("operative/operating-edit-vipactivity");
    	return model;
    }
    
}
